function getContextPath () {
    // 获取当前网址，如：http://localhost:8080/ssm/index.jsp
    var currentPath = window.document.location.href;
    // 获取主机地址之后的目录，如： /ssm/index.jsp
    var pathName = window.document.location.pathname;
    var pos = currentPath.indexOf(pathName);
    // 获取主机地址，如： http://localhost:8080
    var localhostPath = currentPath.substring(0, pos);
    // 获取带"/"的项目名，如：/ssm
    var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);
    return(localhostPath + projectName);
}
function GetQueryString(name){
		var reg=new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
		var r=window.location.search.substr(1).match(reg);
		if(r!=null){
			return unescape(r[2]);
		}
		return null;
	}

	var scrollFunc = function(e) {
		e = e || window.event;
		var id=GetQueryString("id");
		if (e.wheelDelta) {// IE/Opera/Chrome
			if (e.wheelDelta > 0) {
			if(id==null){
				//window.location.href = getContextPath()+"/index.jsp";
				}else{
				id--;
				if(id>0){
				window.location.href = getContextPath()+"/positionAction_getPicId.action?id="+id;
				}else{
				window.location.href = getContextPath()+"/index.jsp";
				}
				}
			} else {
			if(id==null){
				window.location.href = getContextPath()+"/positionAction_getPicId.action?id=1";
				}else{
				id++;
				if(id<6){
				window.location.href = getContextPath()+"/positionAction_getPicId.action?id="+id;
				}
				}
			}
		} else if (e.detail) {// Firefox
			if (e.detail < 0) {
			if(id==null){
				//window.location.href = getContextPath()+"/index.jsp";
				}else{
				id--;
				if(id>0){
				window.location.href = getContextPath()+"/positionAction_getPicId.action?id="+id;
				}else{
				window.location.href = getContextPath()+"/index.jsp";
				}
				}
			} else {
			if(id==null){
				window.location.href = getContextPath()+"/positionAction_getPicId.action?id=1";
				}else{
				id++;
				if(id<6){
				window.location.href = getContextPath()+"/positionAction_getPicId.action?id="+id;
				}
				}
			}
		}
	}
	
	/* 注册事件 */
	if (document.addEventListener) {
		document.addEventListener('DOMMouseScroll', scrollFunc, false);
	}// W3C
	window .onmousewheel = document.onmousewheel = scrollFunc;// IE/Opera/Chrome
